package com.shanghaionstar.carmanage;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.onstar.cn.common.exception.OnStarException;
import com.onstar.cn.common.util.CommonUtil;
import com.onstar.cn.common.util.Constants;
import com.onstar.cn.framework.annotation.ContentView;
import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.annotation.OnClick;
import com.onstar.cn.framework.mvp.base.core.BaseActivity;
import com.onstar.cn.framework.mvp.base.core.BasePresenter;
import com.onstar.cn.ripple.view.RippleCustomBtn;
import com.shanghaionstar.R;
import com.shanghaionstar.carmanage.iview.ICarCheckMaintainView;
import com.shanghaionstar.carmanage.model.CarCheckItem;
import com.shanghaionstar.swipe.SwipeActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mengzhou Gu on 2016/7/25.
 */
@ContentView(R.layout.car_mamage_advice)
public class CarCheckMaintainActivity extends SwipeActivity implements ICarCheckMaintainView,View.OnClickListener{
    @FindViewById
    private LinearLayout oil_life_layout, ove_tire_layout, fuel_tank_layout, maintain_layout, maintain_info_layout,battery_level_layout;
    @FindViewById
    private TextView oil_life, oil_life_hint, oil_life_hint2, ove_tire, ove_tire_hint, fuel_tank_info,
            fuel_tank_info_hint, maintain_info, maintain_info_1,battery_level_info;
    private RippleCustomBtn find_dealer;
    @FindViewById
    private RelativeLayout  layout_background;
    @FindViewById
    private ListView        carcheck_lv;
    private List<String> tireList = new ArrayList<String>();
    private List<CarCheckItem> carCheckItemList=new ArrayList<>();

    @Override
    public BasePresenter getPresenter() {
        return null;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 机油余量
        int oilLife = getIntent().getIntExtra(Constants.OIL_LIFE, -1);
        // 总行驶里程
        int odometer = getIntent().getIntExtra(Constants.ODOMETER, -1);
        // 燃油余量
        int fuelTankInfo = getIntent().getIntExtra(Constants.FUEL_TANK_INFO, -1);
        // 胎压
        // 左前
        String leftFront = getIntent().getStringExtra(Constants.TIRE_PRESSURE_LF);
        // 左后
        String leftRear = getIntent().getStringExtra(Constants.TIRE_PRESSURE_LR);
        // 右前
        String rightFront = getIntent().getStringExtra(Constants.TIRE_PRESSURE_RF);
        // 右后
        String rightRear = getIntent().getStringExtra(Constants.TIRE_PRESSURE_RR);

        if (!CommonUtil.isNull(leftFront) && !CommonUtil.isNull(leftRear) && !CommonUtil.isNull(rightFront)
                && !CommonUtil.isNull(rightRear)) {
            if (ove_tire_layout != null)
                ove_tire_layout.setVisibility(View.VISIBLE);
            if (!tireList.contains("yellow") && !tireList.contains("red")) {
                ove_tire.setText(R.string.tire_info_full);
                ove_tire_hint.setText(R.string.tire_info_full_hint);
                ove_tire.setTextColor(getResources().getColor(R.color.home_green));
            } else if (tireList.contains("red")) {
                ove_tire.setText(R.string.tire_info_risk);
                ove_tire_hint.setText(R.string.tire_info_risk_hint);
                ove_tire.setTextColor(getResources().getColor(R.color.home_red));
            } else {
                ove_tire.setText(R.string.tire_info_low);
                ove_tire_hint.setText(R.string.tire_info_low_hint);
                ove_tire.setTextColor(getResources().getColor(R.color.home_yellow));
            }
        } else {
            ove_tire_layout.setVisibility(View.GONE);
        }
    }




    @Override
    public void setLoading(boolean isLoading) {

    }

    @Override
    public void onResponseError(OnStarException e) {

    }

    @Override
    public void onReponseSuccess(Object object) {

    }

    @Override
    public Activity onActivity() {
        return null;
    }

    @OnClick({R.id.find_dealer})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.find_dealer:
//                BusinessUtil.sendReportByClickType(this,
//                        FunctionNameFindId.Maintenance_contactdealer.getStringValue());
                startActivity(new Intent(this, AroundDealerActivity.class));
                break;
        }
    }
}
